package com.it.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.it.entity.User;
import com.it.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zzc
 * @since 2025-04-16
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@Api(tags = "用户管理接口")
@Slf4j
public class UserController {
    private final IUserService userService;

    /**
     * 查询用户列表
     * @return
     */
    @GetMapping
    @ApiOperation("查询用户列表")
    public List<User> selectAll() {
        List<User> userList = userService.list();
        return userList;
    }

    /**
     * 分页查询
     * @return
     */
    @GetMapping("page")
    @ApiOperation("分页查询")
    public List<User> page(Long currentPage,Long pageSize) {
        //LambdaQueryWrapper<Object> wrapper = new LambdaQueryWrapper<>();
        Page<User> page = userService.page(new Page<>(currentPage, pageSize));
        return page.getRecords();
    }
}
